
import 'package:ysy_flutter_mvvm_yuanxuan/api/HttpService.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/base/BaseModel.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/base/PullPageBean.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/bean/base/BaseBean.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/bean/base/BaseListDataBean.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/bean/home/HomeAttentionPageBean.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/bean/home/HomeCategoryTabBean.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/bean/home/HomeAttentionBean.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/bean/home/RecommendCategoryBean.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/bean/home/RecommendGoodsBean.dart';
import '../../../bean/home/HomeContentBean.dart';

class HomeVM extends BaseModel{

  HomeContentBean?  homeBean;
  HomeAttentionBean?  attentionBean;
  RecommendCategoryTabBean? recommendCategoryTab;
  BaseListDataBean<RecommendGoods>? recommendGoodsBeans;
  BaseListDataBean<AttentionPageBean>? attentionPageBeans;

  //首页商品列表 分页管理版
  PullPageBean goodsListPage=PullPageBean();

  //首页-推荐 头部数据
  void getRecommend({bool isDialog=true,RequestDone? requestDone}){
     onNetWorkVerdictAndData(future: recommend(), result: (str){
        homeBean=BaseDataBean<HomeContentBean>.fromJson(str,(map) => HomeContentBean.fromJson(map)).data;
     },isDialog:isDialog,done: requestDone);
  }

  // 首页-推荐 分类
  void getRecommendCategory(){
    onNetWorkVerdictAndData(future: recommendCategory(), result: (str){
      recommendCategoryTab=RecommendCategoryTabBean(BaseToListBean<RecommendCategory>.fromJson(str,(map)=>RecommendCategory.fromJson(map)).data);
     },isDialog: false);
  }

  // 首页-推荐 商品列表
  void getRecommendGoods(PullPageBean pullPageBean,int? type,{RequestDone? requestDone}){
    onNetWorkVerdictAndData(future: recommendGoodsList(type,pullPageBean.pageSize,pullPageBean.pageNum), result: (str){
       recommendGoodsBeans=BaseListBean<RecommendGoods>.fromJson(str,(map) => RecommendGoods.fromJson(map)).data;
    },isDialog: false,done: requestDone);
  }

  //首页-关注 头部数据
  void getAttention({bool isDialog=true,RequestDone? requestDone}){
    onNetWorkVerdictAndData(future: attention(), result: (str){
      attentionBean=BaseDataBean<HomeAttentionBean>.fromJson(str,(map) => HomeAttentionBean.fromJson(map)).data;
    },isDialog:isDialog,done: requestDone);
  }

  //首页-关注 列表
  void getAttentionList(PullPageBean pullPageBean,{bool isDialog=true,RequestDone? requestDone}){
    onNetWorkVerdictAndData(future: attentionList(pullPageBean.pageSize,pullPageBean.pageNum), result: (str){
      attentionPageBeans=BaseListBean<AttentionPageBean>.fromJson(str,(map) => AttentionPageBean.fromJson(map)).data;
    },isDialog:isDialog,done: requestDone);
  }

}